package com.glq1218.file.controller;

import com.glq1218.file.dto.FileUploadResp;
import com.glq1218.file.service.CosService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author glq1218
 * @description TODO
 * @since 2023/4/27 15:31
 */
@RestController
@RequestMapping("/api/file")
@RequiredArgsConstructor
public class FileController {
    private final CosService cosService;

    @PostMapping("/uploadFile")
    public FileUploadResp uploadFile(@RequestParam("file") MultipartFile file) {
        String url = cosService.uploadFile(file, 2);
        return new FileUploadResp(url);
    }
}
